from django.contrib.auth.models import User
from django.core.management.base import BaseCommand

from apps.oaauth.models import OAUser


class Command(BaseCommand):
    def handle(self, *args, **options):
        realname = "孙七"
        new_password = "sunqisunqi"
        # 获取用户对象
        user = OAUser.objects.get(realname=realname)
        # 设置新密码
        user.set_password(new_password)
        # 保存更改
        user.save()

        self.stdout.write('用户更新完成')
